<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>
                <div class="row">
                    <div class="col-sm-22 widget-container-col ui-sortable" id="widget-container-col-10">
                        <div class="widget-box ui-sortable-handle" id="widget-box-10">
                            <div class="widget-header widget-header-small">
                                <h5 class="widget-title smaller">文件信息</h5>
                            </div>
                            <div class="widget-body">
                                <div class="widget-main padding-6" style="overflow: hidden">
                                    <div class="tab-content">
                                        <div id="home" class="tab-pane active">
                                            <div class="col-xs-12">
                                                <!-- PAGE CONTENT BEGINS -->
                                                <form class="form-horizontal"
                                                      action="<?php echo site_url(X_URL . 'file/update'); ?>"
                                                      method="post" id="from1">
                                                    <?php echo csrf_hidden(); ?>
                                                    <input type="hidden" name="file_id"
                                                           value="<?php if (!empty($file_id)) {
                                                               echo $file_id;
                                                           } ?>">
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right"
                                                               for="form-field-1"> 文件标题 </label>
                                                        <div class="col-sm-9">
                                                            <input type="text" name="file_name"
                                                                   class="rcol-xs-10 col-sm-5"
                                                                   value="<?php if (isset($file)) {
                                                                       echo $file["file_name"];
                                                                   } ?>">
                                                            <input type="hidden" name="file_id"
                                                                   value="<?php if (isset($file)) {
                                                                       echo $file["id"];
                                                                   } ?>">
                                                            <span class="help-inline col-xs-12 col-sm-7">
                											     <span class="middle">请填写文件标题</span>
                											</span>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label no-padding-right"
                                                               for="form-field-4">文件上传 </label>
                                                        <div class="col-sm-6">
                                                            <div class="file-loading">
                                                                <input id="kv-explorer" name="file" type="file"
                                                                       accept="file/*">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <input type="hidden" id="file_location"
                                                           value="<?php echo $file_location ?? '' ?>"
                                                           name="file_location">
                                                    <input type="hidden" id="file_real_name"
                                                           value="<?php echo $file_real_name ?? '' ?>"
                                                           name="file_real_name">
                                                    <div class="col-md-offset-2 col-md-9">
                                                        <button class="btn btn-info" type="submit" id="subForm1">
                                                            <i class="icon-ok bigger-110"></i>
                                                            提交
                                                        </button>

                                                        &nbsp; &nbsp; &nbsp;
                                                        <button class="btn" type="reset">
                                                            <i class="icon-undo bigger-110"></i>
                                                            重置
                                                        </button>
                                                    </div>

                                                </form>
                                                <!-- PAGE CONTENT ENDS -->
                                            </div><!-- /.col -->
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /section:settings.box -->
                <div class="row">

                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer'); ?>
</div><!-- /.main-container -->
<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {


        $("#subForm1").click(function () {
            var file_name = $("#file_name").val();
            if (file_name == '') {
                bootbox.dialog({
                    title: '友情提示：',
                    message: "文件标题必须填写。",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return;
            }
            $("#from1").submit();
        });

        var picpath = <?php echo $pic_path;?>;
        var piccon = <?php echo $pic_con;?>;
        $(document).ready(function () {
            $("#kv-explorer").fileinput({
                language: 'zh',
                uploadAsync: false, //设置上传同步异步 此为同步
                dropZoneEnabled: false,
                showCaption: false,//是否显示标题
                showPreview: true,
                autoReplace: true,
                showRemove: false,
                'theme': 'explorer-fa',
                'uploadUrl': baseurl + 'index.php/upload/upload_file',
                overwriteInitial: false,
                initialPreviewAsData: false,
                layoutTemplates: {
                    actionUpload: '',//去除上传预览缩略图中的上传图片
                    actionZoom: '',   //去除上传预览缩略图中的查看详情预览的缩略图标
                    actionDownload: '', //去除上传预览缩略图中的下载图标
                },
                initialPreview: picpath, //要显示的图片的路径
                initialPreviewConfig: piccon
            })
            ;
            $("#kv-explorer").on("filebatchuploadsuccess", function (event, data) {
                var rst = data.response;
                var path = rst.path;
                var name = rst.name;
                $("#file_location").val(path);
                $("#file_real_name").val(name);
            });
        });
    });
</script>
</body>
</html>
